package com.xintai.sparepart.spareandpart.controller;

import java.text.ParseException;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xintai.common.annotation.Log;
import com.xintai.common.core.controller.BaseController;
import com.xintai.common.core.domain.AjaxResult;
import com.xintai.common.enums.BusinessType;
import com.xintai.sparepart.spareandpart.domain.BeiUrgenttime;
import com.xintai.sparepart.spareandpart.service.IBeiUrgenttimeService;

/**
 * 紧急出库时间设置Controller
 *
 * @author xintai
 * @date 2020-12-29
 */
@RestController
@RequestMapping("/sparepart/urgenttime")
public class BeiUrgenttimeController extends BaseController
{
    @Autowired
    private IBeiUrgenttimeService beiUrgenttimeService;

    /**
     * 获取紧急出库时间设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('sparepart:urgenttime:query')")
    @GetMapping(value = "/{beiId}")
    public AjaxResult getInfo(@PathVariable("beiId") Long beiId)
    {
        return AjaxResult.success(beiUrgenttimeService.selectBeiUrgenttimeById(beiId));
    }

    /**
     * 新增紧急出库时间设置
     */
    @PreAuthorize("@ss.hasPermi('sparepart:urgenttime:add')")
    @Log(title = "紧急出库时间设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BeiUrgenttime beiUrgenttime) throws ParseException {
        return toAjax(beiUrgenttimeService.insertBeiUrgenttime(beiUrgenttime));
    }

    /**
     * 修改紧急出库时间设置
     */
    @PreAuthorize("@ss.hasPermi('sparepart:urgenttime:edit')")
    @Log(title = "紧急出库时间设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BeiUrgenttime beiUrgenttime)
    {
        return toAjax(beiUrgenttimeService.updateBeiUrgenttime(beiUrgenttime));
    }


}
